fix(mcp): open the OAuth popup synchronously and bound the start request#5824
Conversation
Two bugs behind 'pressed Connect/Reopen and nothing happened': - window.open ran AFTER awaiting /oauth/start, outside the browser's user activation, so the popup was silently blocked (worst on the add-server flow). Popup-first now: open about:blank synchronously in the click (named window, so a re-click focuses/reuses an existing authorization window), navigate it once the start returns; close it on failure/already_authorized; clear toast when genuinely blocked (and skip the request entirely). - /oauth/start had no client timeout, so a stalled start held the re-entrancy guard and the connecting label indefinitely. Bounded at 30s; on timeout the popup closes, the label resets, and retry is immediately available.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Popup-first: Reconnect / reopen: Opening the named window blanks any prior auth tab, so Bounded start: Reviewed by Cursor Bugbot for commit d3b754f. Configure here. |
Greptile SummaryThis PR improves the MCP OAuth authorization flow. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (3): Last reviewed commit: "fix(mcp): close the blank popup when pos..." | Re-trigger Greptile |
- Retire prior flows as soon as the named popup opens (the open already blanked any prior auth window; a failed start must not leave a windowless flow 'connecting' for the 10-minute safety timeout). - Check the COOP-fallback window.open result; when blocked, clear the state and toast instead of registering a windowless pending flow. - Feature-detect AbortSignal.timeout (Safari <16) with an AbortController fallback for the bounded /oauth/start.
|
@cursor review |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit d3b754f. Configure here.
Summary
Fixes the two reported OAuth UX failures (no popup after Add MCP; 'Reopen authorization window' pressing doing nothing):
window.openpreviously ran after awaiting/api/mcp/oauth/start, outside the browser's user-activation window, so the popup was silently blocked — worst on the add-server flow (two awaits deep). The hook now opensabout:blanksynchronously in the click (named per server, so a re-click focuses/reuses an existing authorization window), navigates it once the start returns, and closes it on failure/already_authorized. A genuinely blocked popup shows a clear toast and skips the request entirely./oauth/starthad no client-side timeout, so a stalled start (the known transient body-stall) held the re-entrancy guard and the connecting label indefinitely — the button looked dead. The request is now bounded at 30s; on timeout the popup closes, the label resets to 'Connect with OAuth', and retry is immediately available.authorizationUrl+state); popup lifecycle lives in one place.Residual note: the add-server auto-start still sits after the create request, so an extremely slow create+probe can still exceed the activation window — but it now degrades to a clear 'Popup blocked' toast and a clean, clickable 'Connect with OAuth' state instead of a stuck label.
Type of Change
Testing
Checklist